﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <link href="../lib/layui/css/layui.css" rel="stylesheet" />
    <link href="../lib/layui/lay/plugins/eleTree/font/eleTree.css" rel="stylesheet" />
    <script src="../lib/Base64/base64.js"></script>
    <script src="../lib/cookie/cookie.js"></script>
    <script src="../linq.js/linq.js"></script>
    <script src="../lib/layui/layui.js"></script>
    <style>
        .layui-form-item .layui-input-inline {
            width: 280px;
        }
    </style>
</head>

<body style="background-color:#eee;">
    <div class="layui-fluid">
        <form class="layui-form" lay-filter="processPackagForm">
            <div class="layui-form-item" style="margin-top:10px;">
                <label class="layui-form-label">备注信息：</label>
                <div class="layui-input-block">
                    <input type="text" name="remark" id="remark" placeholder="请输入备注信息" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">文件目录：</label>
                <div class="layui-input-block">
                    <textarea name="packagDir" id="packagDir" placeholder="请输入文件目录,多个用;隔开" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item" style="text-align:center;">
                <a class="layui-btn" href="javascript:;" lay-submit lay-filter="packag">提交</a>
            </div>
        </form>
    </div>
    <script type="text/javascript">
        function getrequest() {
            var url = location.search; //获取url中"?"符后的字串
            var theRequest = new Object();
            if (url.indexOf("?") != -1) {
                var str = url.substr(1);
                strs = str.split("&");
                for (var i = 0; i < strs.length; i++) {
                    theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
                }
            }
            return theRequest;
        }
        layui.config({
            base: '/lib/layui/lay/plugins/'
        }).extend({
            eleTree: 'eleTree/eleTree'
        }).use(['form', 'eleTree'], function () {
            var form = layui.form;
            var $ = layui.$;
           
            form.on('submit(packag)', function (data) {
                data.elem.removeAttribute("lay-submit");
                data.field.PackagType = "2";
                var paths = data.field.packagDir.replace(/\n/g, "").replace("；", ";");
                data.field.dirs = paths.split(";");
                var i = layui.layer.load();
                layui.$.ajax({
                    type: 'post',
                    url: localStorage.getItem('hosttingaddr') + '/api/Packag/packagfile',
                    headers: {
                        user: getCookie("userinfo"),
                        version: getCookie("version")
                    },
                    dataType: 'json',
                    contentType: 'application/json;charset=utf-8',
                    data: JSON.stringify(data.field),
                    success: function (re) {
                        layui.layer.close(i);
                        if (re.code == 0) {
                            layer.msg('正在打包，请稍等!', { icon: 1, time: 1000 });
                            parent.layui.table.reload('packagTable');
                            var index = parent.layer.getFrameIndex(window.name); //获取当前窗口的name
                            parent.layer.close(index);
                        }
                    },
                    error: function (data) {
                        layer.msg('打包失败!', { icon: 1, time: 1000 });
                        parent.layui.table.reload('packagTable');
                        var index = parent.layer.getFrameIndex(window.name); //获取当前窗口的name

                        parent.layer.close(index);
                    }
                });

                data.elem.setAttribute("lay-submit", true);
                return false;
            });
        });



    </script>
</body>
</html>